﻿using Inovout.Repositories;
using Inovout.Services;

namespace Inovout.Security
{
    public class SecurityDataInitiator : DataInitiator
    {
        private IRepositoryService<FormsUserCredential> formsUserCredentialService;
        private IRepositoryService<Role> roleService;
        public SecurityDataInitiator(IRepositoryService<FormsUserCredential> formsUserCredentialService, IRepositoryService<Role> roleService)
        {
            this.formsUserCredentialService = formsUserCredentialService;
            this.roleService = roleService;
        }
        public override void Initializate()
        {
            Role administratorsRole = new Role { Name = "Administrators" };
            roleService.Save(administratorsRole);

            FormsUserCredential adminUser = new FormsUserCredential
            {
                UserName = "admin",
                Password = "123456",
            };
            //adminUser.Roles.Add(administratorsRole);
            formsUserCredentialService.Save(adminUser);

            roleService.Save(new Role { Name = "Developers" });
        }
    }
}
